#include <wx/wx.h>
#include <wx/menu.h>
#include <wx/menuitem.h>

class SimpleMenu : public wxFrame
{
public:
    SimpleMenu(const wxString& title, const wxPoint& pos, const wxSize& size)
        : wxFrame(NULL, wxID_ANY, title, pos, size)
    {
        wxMenu *menuFile = new wxMenu;
        menuFile->Append(wxID_EXIT, wxT("&Quit"), "Quit application test");
        menuFile->Append(wxID_OPEN, "&Open", "Open file");

        wxMenu *imp = new wxMenu;
        imp->Append(wxID_ANY, wxT("Import newsfeed list..."));
        imp->Append(wxID_ANY, wxT("Import bookmarks..."));
        imp->Append(wxID_ANY, wxT("Import mail..."));

        menuFile->AppendSubMenu(imp, wxT("I&mport"));

        wxMenu *menuHelp = new wxMenu;
        menuHelp->Append(wxID_ABOUT, "&About", "About application");

        wxMenuBar *menuBar = new wxMenuBar;
        menuBar->Append(menuFile, "&File");
        menuBar->Append(menuHelp, "&Help");

        SetMenuBar(menuBar);

        wxImage::AddHandler(new wxPNGHandler);
        wxBitmap exit(wxT("exit.png"), wxBITMAP_TYPE_PNG);
        wxToolBar *toolbar = CreateToolBar();
        toolbar->AddTool(wxID_EXIT, 
                        wxT("Exit application"),
                        exit,exit);
        toolbar->Realize();

        CreateStatusBar();
        SetStatusText("Welcome to wxWidgets!");

        Bind(wxEVT_MENU, &SimpleMenu::OnQuit, this, wxID_EXIT);
        Bind(wxEVT_MENU, &SimpleMenu::OnOpen, this, wxID_OPEN);
        Bind(wxEVT_MENU, &SimpleMenu::OnAbout, this, wxID_ABOUT);

        Centre();
    }

private:
    void OnQuit(wxCommandEvent& event)
    {
        Close(true);
    }

    void OnOpen(wxCommandEvent& event)
    {
        wxLogMessage("Open menu item clicked");
    }

    void OnAbout(wxCommandEvent& event)
    {
        wxMessageBox("This is a wxWidgets Hello World example",
                     "About Hello World", wxOK | wxICON_INFORMATION);
    }
};

class MyApp : public wxApp
{
public:
    virtual bool OnInit()
    {
        SimpleMenu *frame = new SimpleMenu("Simple Menu", wxPoint(50, 50), wxSize(450, 340));
        frame->Show(true);

        return true;
    }
};

wxIMPLEMENT_APP(MyApp);